<template>
  <div class="feedback-container">
    <div class="feedback-header">
      <el-button type="text" @click="goBack" class="back-button">
        <el-icon><ArrowLeft /></el-icon>
        返回
      </el-button>
      <h1>面试反馈</h1>
    </div>
    
    <div class="feedback-content">
      <div class="interview-info">
        <div class="position-info">
          <h2>{{ interviewData.position }}</h2>
          <p class="company">{{ interviewData.company }}</p>
        </div>
        
        <div class="result-status">
          <el-tag type="danger" size="large">
            面试未通过
          </el-tag>
        </div>
      </div>
      
      <div class="feedback-sections">
        <!-- 综合评价 -->
        <div class="feedback-section">
          <div class="section-header">
            <h3>综合评价</h3>
          </div>
          <div class="section-content">
            <div class="overall-score">
              <div class="score-circle">
                <el-progress
                  type="circle"
                  :percentage="interviewData.overallScore"
                  :width="100"
                  :stroke-width="8"
                  :color="getScoreColor(interviewData.overallScore)"
                />
              </div>
              <div class="score-info">
                <p class="score-text">综合得分</p>
                <p class="score-value">{{ interviewData.overallScore }}/100</p>
              </div>
            </div>
            
            <div class="evaluation-summary">
              <p>{{ interviewData.overallFeedback }}</p>
            </div>
          </div>
        </div>
        
        <!-- 各项评分 -->
        <div class="feedback-section">
          <div class="section-header">
            <h3>各项评分</h3>
          </div>
          <div class="section-content">
            <div class="score-items">
              <div 
                v-for="item in interviewData.scoreItems" 
                :key="item.name"
                class="score-item"
              >
                <div class="item-header">
                  <span class="item-name">{{ item.name }}</span>
                  <span class="item-score">{{ item.score }}/100</span>
                </div>
                <el-progress
                  :percentage="item.score"
                  :stroke-width="6"
                  :color="getScoreColor(item.score)"
                />
                <p class="item-feedback">{{ item.feedback }}</p>
              </div>
            </div>
          </div>
        </div>
        
        <!-- 改进建议 -->
        <div class="feedback-section">
          <div class="section-header">
            <h3>改进建议</h3>
          </div>
          <div class="section-content">
            <div class="suggestions">
              <div 
                v-for="suggestion in interviewData.suggestions" 
                :key="suggestion.id"
                class="suggestion-item"
              >
                <div class="suggestion-icon">
                  <el-icon><Sunny /></el-icon>
                </div>
                <div class="suggestion-content">
                  <h4>{{ suggestion.title }}</h4>
                  <p>{{ suggestion.content }}</p>
                </div>
              </div>
            </div>
          </div>
        </div>
        
        <!-- 推荐学习资源 -->
        <div class="feedback-section">
          <div class="section-header">
            <h3>推荐学习资源</h3>
          </div>
          <div class="section-content">
            <div class="resources">
              <div 
                v-for="resource in interviewData.resources" 
                :key="resource.id"
                class="resource-item"
              >
                <div class="resource-icon">
                  <el-icon><Document /></el-icon>
                </div>
                <div class="resource-content">
                  <h4>{{ resource.title }}</h4>
                  <p>{{ resource.description }}</p>
                  <el-button type="primary" link @click="openResource(resource.link)">
                    查看资源
                  </el-button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      
      <div class="feedback-actions">
        <el-button @click="downloadFeedback">
          <el-icon><Download /></el-icon>
          下载反馈报告
        </el-button>
        <el-button type="primary" @click="goToPractice">
          <el-icon><Edit /></el-icon>
          去练习提升
        </el-button>
      </div>
    </div>
  </div>
</template>

<script>
import { ref, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { 
  ArrowLeft, 
  Sunny, 
  Document, 
  Download, 
  Edit 
} from '@element-plus/icons-vue'

export default {
  name: 'InterviewFeedbackView',
  components: {
    ArrowLeft,
    Sunny,
    Document,
    Download,
    Edit
  },
  setup() {
    const route = useRoute()
    const router = useRouter()
    
    const interviewData = ref({
      position: '前端开发工程师',
      company: '创新科技有限公司',
      overallScore: 45,
      overallFeedback: '整体表现有待提升。在技术基础方面存在一些不足，需要加强相关知识的学习。同时，在问题解决和沟通表达方面也有改进空间。建议多做练习，提升技能水平。',
      scoreItems: [
        {
          name: '简历匹配度',
          score: 60,
          feedback: '教育背景和工作经验基本符合要求，但在相关项目经验方面略有不足。'
        },
        {
          name: '逻辑思维',
          score: 40,
          feedback: '在算法和数据结构问题上表现不佳，需要加强逻辑思维训练。'
        },
        {
          name: '技术能力',
          score: 35,
          feedback: '对前端技术栈的掌握程度有限，需要深入学习相关技术。'
        },
        {
          name: '沟通表达',
          score: 50,
          feedback: '表达基本清晰，但在技术问题的阐述上还需要更加准确和深入。'
        },
        {
          name: '问题解决',
          score: 45,
          feedback: '解决问题的思路需要更加系统化，建议多练习实际项目案例。'
        }
      ],
      suggestions: [
        {
          id: 1,
          title: '加强技术基础',
          content: '建议系统学习JavaScript、Vue.js、React等前端技术，并通过实际项目练习加深理解。'
        },
        {
          id: 2,
          title: '提升算法能力',
          content: '多做算法题，特别是数据结构和算法相关的练习，提升逻辑思维能力。'
        },
        {
          id: 3,
          title: '改善沟通技巧',
          content: '练习技术问题的表达，学会用简洁明了的方式解释复杂的技术概念。'
        },
        {
          id: 4,
          title: '积累项目经验',
          content: '多参与实际项目开发，积累更多的实战经验和解决问题的能力。'
        }
      ],
      resources: [
        {
          id: 1,
          title: 'JavaScript 进阶教程',
          description: '深入学习JavaScript语言特性和高级应用',
          link: '#'
        },
        {
          id: 2,
          title: '前端面试题集锦',
          description: '常见前端面试题目和答案解析',
          link: '#'
        },
        {
          id: 3,
          title: '算法训练平台',
          description: '在线算法练习和竞赛平台',
          link: '#'
        },
        {
          id: 4,
          title: '项目实战案例',
          description: '前端项目开发实战案例和最佳实践',
          link: '#'
        }
      ]
    })
    
    const getScoreColor = (score) => {
      if (score >= 80) return '#67C23A'
      if (score >= 60) return '#E6A23C'
      return '#F56C6C'
    }
    
    const goBack = () => {
      router.go(-1)
    }
    
    const downloadFeedback = () => {
      // 实现下载反馈报告的逻辑
      console.log('下载反馈报告')
    }
    
    const goToPractice = () => {
      router.push('/candidate/practice')
    }
    
    const openResource = (link) => {
      // 实现打开学习资源的逻辑
      console.log('打开资源:', link)
    }
    
    onMounted(() => {
      // 根据路由参数加载相应的面试反馈数据
      const interviewId = route.query.id
      console.log('加载面试ID:', interviewId, '的反馈数据')
    })
    
    return {
      interviewData,
      getScoreColor,
      goBack,
      downloadFeedback,
      goToPractice,
      openResource
    }
  }
}
</script>

<style scoped>
.feedback-container {
  min-height: 100vh;
  background: #f8f9fa;
  padding: 20px;
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.back-button {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #e4e7ed;
  background: white;
}

.feedback-header h1 {
  color: #333;
  margin: 0;
}

.feedback-content {
  max-width: 1000px;
  margin: 0 auto;
}

.interview-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  padding: 24px;
  border-radius: 8px;
  margin-bottom: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.position-info h2 {
  color: #333;
  margin: 0 0 8px 0;
}

.company {
  color: #666;
  margin: 0;
  font-size: 16px;
}

.feedback-sections {
  display: grid;
  gap: 24px;
}

.feedback-section {
  background: white;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.section-header {
  border-bottom: 2px solid #f0f2f5;
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.section-header h3 {
  color: #333;
  margin: 0;
}

.overall-score {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
}

.score-info {
  flex: 1;
}

.score-text {
  color: #666;
  margin: 0 0 8px 0;
}

.score-value {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.evaluation-summary {
  color: #666;
  line-height: 1.6;
}

.score-items {
  display: grid;
  gap: 24px;
}

.score-item {
  padding: 16px;
  background: #f8f9fa;
  border-radius: 6px;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.item-name {
  font-weight: 500;
  color: #333;
}

.item-score {
  color: #666;
  font-size: 14px;
}

.item-feedback {
  color: #666;
  margin-top: 8px;
  margin-bottom: 0;
  font-size: 14px;
}

.suggestions {
  display: grid;
  gap: 16px;
}

.suggestion-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 6px;
}

.suggestion-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e6f7ff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1890ff;
}

.suggestion-content h4 {
  color: #333;
  margin: 0 0 8px 0;
}

.suggestion-content p {
  color: #666;
  margin: 0;
  line-height: 1.5;
}

.resources {
  display: grid;
  gap: 16px;
}

.resource-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 6px;
}

.resource-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f0f9ff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6753C0;
}

.resource-content {
  flex: 1;
}

.resource-content h4 {
  color: #333;
  margin: 0 0 8px 0;
}

.resource-content p {
  color: #666;
  margin: 0 0 8px 0;
  line-height: 1.5;
}

.feedback-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid #e4e7ed;
}

@media (max-width: 768px) {
  .interview-info {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
  .overall-score {
    flex-direction: column;
    text-align: center;
  }
  
  .feedback-actions {
    flex-direction: column;
  }
}
</style> 